<?php
  
$conn = mysql_connect('studentdb.gl.umbc.edu', 'chrimo1', 'chrimo1');
if (!$conn) {
   die('Could not connect');
}

$db_selected = mysql_select_db('chrimo1', $conn);
if (!$db_selected) {
   die ('Can\'t use chrimo1');
}


$gameName = mysql_real_escape_string($_POST['gameName']);
$developer = mysql_real_escape_string($_POST['developer']);
$releaseDate = $_POST['releaseDate'];
$description = mysql_real_escape_string($_POST['description']);
$system = $_POST['system'];
$quantity = $_POST['quantity'];
$price = $_POST['price'];
$imageURL = mysql_real_escape_string($_POST['imageURL']);

$multiplayer = $_POST['multiplayer'];
$singleplayer = $_POST['singleplayer'];
$cooperative = $_POST['cooperative'];
$beatemUp = $_POST['beatemUp'];
$rpg = $_POST['rpg'];
$platform = $_POST['platform'];
$action = $_POST['action'];
$strategy = $_POST['strategy'];
$shootemUp = $_POST['shootemUp'];
$buildingSim = $_POST['buildingSim'];
$scrollingShooter = $_POST['scrollingShooter'];
$racing = $_POST['racing'];
$sports = $_POST['sports'];

echo '<body style="background-color:black">';

if($gameName == ''){

	echo '<center><h1 style="color:red; font-size: 42">ERROR! Game not Added</h1></center>';
	echo '<center><h1 style="color:red; font-size: 42">You Must enter a game name! Hit the back button.</h1></center>';
}
else{

  $sql = "INSERT INTO gameInventory (gameName, developer, description, releaseDate, quantity, price, imageURL, system, multiplayer, singleplayer, cooperative, beatemUp, rpg, platform, action, strategy, shootemUp, buildingSim, scrollingShooter, racing, sports)
  VALUES('".$gameName."', '".$developer."', '".$description."', '".$releaseDate."', '".$quantity."', '".$price."', '".$imageURL."', '".$system."', '".$multiplayer."', '".$singleplayer."', '".$cooperative."', '".$beatemUp."', '".$rpg."', '".$platform."', '".$action."', '".$strategy."', '".$shootemUp."', '".$buildingSim."', '".$scrollingShooter."', '".$racing."', '".$sports."')";

  $exec = mysql_query($sql, $conn);

  
  if ($exec){
    echo '<center><h1 style="color:green; font-size: 42">Game Added to Inventory!</h1></center>';
  }
  else{
    echo '<center><h1 style="color:red; font-size: 42">ERROR! Game not Added</h1></center>';
  }
}
echo '<center><h2><a style="color:gold" href="addInventory.php">Add Another Game</a></h2></center>';
echo '<center><h2><a style="color:gold" href="admin.html"><img src="images/admin_button.png"></a></h2></center>';

?>